<!DOCTYPE html>
<% 
response.setHeader("X-UA-Compatible","IE=edge,chrome=1");
response.setHeader("Cache-Control","no-cache, no-store, must-revalidate");
response.setHeader("Pragma","no-cache");
response.setHeader("Expires","0");
%><html class="index" lang="en" ng-app="myApp">
	<head>
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta charset="utf-8">
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<base href="<%=request.getScheme()%>://<%=request.getServerName()%>:<%=request.getServerPort()%>/chat/">
		<title>Secure Chat</title>
		<% String verNumber = "1.4." + (int)(Math.random() * 100000); String ver = "?v=" + verNumber; %>
		<link rel="shortcut icon" href="favicon.ico<%=ver%>"/>
		<link rel="stylesheet" href="includes/css/style.css<%=ver%>" type="text/css" media="screen" />
		<link rel="stylesheet" href="includes/css/avatars.css<%=ver%>" type="text/css" media="screen" />
		<script  type="text/javascript">
			var software = {
					version: '<%=ver%>',
					versionNumber: '<%=verNumber%>',
					versionDate: '4/4/2014',
					name: 'Secure Chat'
			};
		</script>
	</head>
	<body>
		<div class="container" ng-controller="ChatCtrl">
			<div ng-if="room" class="wrapper">
				<header>Secure Chat: {{room}}</header>
				<div id="left-nav">
					<div id="current-user">
						{{name}} <div class="avatar {{avatarClass}}" ng-if="avatarClass"></div>
					</div>
					<div class="user-list" ng-repeat="user in users">
						<div class="avatar {{user.avatarClass}}" ng-if="user.avatarClass"></div> {{user.name}}
					</div>
				</div>
				<div id="chat-area">
					<div id="chat-box" scroll-glue ng-model="glued">
						<div ng-repeat="message in handleMessages(messages) track by $index" ng-bind-html="message">{{message}}</div>
					</div>
					<div id="input-box">
						<form ng-submit="send()">
							<textarea ng-model="$parent.chatText" ng-keypress="submit($event)" required placeholder="Chat Message"></textarea>
							<div class="buttons">
								<button type="submit">Send</button>
								<button type="button">File</button>
							</div>
						</form>
					</div>
				</div>
			</div>
			<div ng-if="!room" id="login">
				<form name="loginform">
					<input type="text" ng-model="req.fname" placeholder="Full Name" required/>
					<input type="text" ng-model="req.name" placeholder="Username" required maxlength="10"/>
					<input type="text" ng-model="req.room" placeholder="Room" required/>
					<select ng-model="avatarKey" ng-options="avatar for avatar in avatarKeys">
						<option value="" class="sel-placeholder">Avatar Category</option>
					</select>
					<div class="avatar {{req.avatar}}" ng-if="req.avatar"></div>
					<button ng-click="joinRoom()" ng-disabled="!loginform.$valid">Join</button>
				</form>
				<div ng-if="avatarKey" id="avatar-selector">
					<h3 ng-if="avatarKey">Avatar:</h3>
					<div ng-if="avatarKey" class="avatars">
						<div class="avatar {{avatar}}" ng-repeat="avatar in avatarList[avatarKey]" ng-click="req.avatar = avatar"></div>
					</div>
				</div>
			</div>
		</div>
		
		<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.5/angular.min.js"></script>
		<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.5/angular-animate.min.js"></script>
		<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.5/angular-sanitize.min.js"></script>
		<script type="text/javascript" src="app/directives/scrollGlue.js<%=ver%>"></script>
		<%--
		<script type="text/javascript" src="app/secureChat.min.js<%=ver%>"></script>
		--%>
		
		<script type="text/javascript" src="app/secureChat.js<%=ver%>"></script>

		<script type="text/javascript" src="app/controllers/chat.js<%=ver%>"></script>

		<script type="text/javascript" src="app/filters/sanitize.js<%=ver%>"></script>
		
		<script type="text/javascript" src="app/services/socket.js<%=ver%>"></script>
	</body>
</html>